authApp.value('page','material_source'); 
authApp.controller("resourceDataController",function($scope,$http,$cookies,$getQueryString){
	if($getQueryString("isfill")=="2"){
		$scope.schoolId=$getQueryString("schoolId");
		$scope.isHideAction=true;
	}
	$scope.savaInfo=function(type){
		var confirmHtml="是否保存";
		if(type=="sub"){
			confirmHtml="是否提交";
		}
		if(window.confirm(confirmHtml)){
			var methodUrl=apis.insertresourceData;
			var methodStatus="0";
			var alertMsg="保存成功";
			if($getQueryString("isfill")=="1"){
				methodUrl=apis.updateResourceData;
			}else if($getQueryString("isfill")=="0"){
				methodUrl=apis.insertresourceData;
			}else{
				$scope.isHideAction=true;
			}
			if(type=="su"){
				methodStatus="0";
				alertMsg="保存成功";
			}else if(type=="sub"){
				methodStatus="1";
				alertMsg="提交成功";
			}
			$http({
				method:'post',
				url:methodUrl,
				data:{
					'totalLibraryCollection':$scope.totalLibraryCollection,
					'electronicBooks':$scope.electronicBooks,
					'relatedProfessionalBooks':$scope.relatedProfessionalBooks,
					'studentRelatedProfessionalBooks':$scope.studentRelatedProfessionalBooks,
					'recommendedBook':$scope.recommendedBook,
					'averageAnnualBook':$scope.averageAnnualBook,
					'readingroomJournals':$scope.readingroomJournals,
					'studentsFreeReading':$scope.studentsFreeReading,
					'studentsDigitalResources':$scope.studentsDigitalResources,
					'professionalJournals':$scope.professionalJournals,
					'skillsTrainingRoomArea':$scope.skillsTrainingRoomArea,
					'sharedArea':$scope.sharedArea,
					'skillsTrainingRoomTypes':$scope.skillsTrainingRoomTypes,
					'sharedRoom':$scope.sharedRoom,
					'equipmentCost':$scope.equipmentCost,
					'sharedDeviceValue':$scope.sharedDeviceValue,
					'status':methodStatus,
					'remark1':$scope.remark1,
					'remark2':$scope.remark2,
					'remark3':$scope.remark3,
					'remark4':$scope.remark4,
					'remark5':$scope.remark5,
					'remark6':$scope.remark6,
					'remark7':$scope.remark7,
					'remark8':$scope.remark8,
					'remark9':$scope.remark9,
					'remark10':$scope.remark10,
					'remark11':$scope.remark11,
					'remark12':$scope.remark12,
					'remark13':$scope.remark13,
					'remark14':$scope.remark14,
					'remark15':$scope.remark15,
					'remark16':$scope.remark16,
				},
			}).success(function(response){
				if(response.code=="000000"){
					alert(alertMsg);
					location.href="../datafill.html";
				}else{
					alert(response.errorMsg);
				}
				$scope.judeAllList=response.data;
			})
		}
	}
	$scope.getInfo=function(){
		//alert("xxxxxxxxxx");
		$http({
			method:'get',
			url:apis.queryResourceDataBySchoolId1,
			params:{'schoolid':$scope.schoolId},
		}).success(function(response){
			if(response.code=="000000"){
				$scope.totalLibraryCollection=response.data.totalLibraryCollection;
				$scope.electronicBooks=response.data.electronicBooks;
				$scope.relatedProfessionalBooks=response.data.relatedProfessionalBooks;
				$scope.studentRelatedProfessionalBooks=response.data.studentRelatedProfessionalBooks;
				$scope.recommendedBook=response.data.recommendedBook;
				$scope.averageAnnualBook=response.data.averageAnnualBook;
				$scope.readingroomJournals=response.data.readingroomJournals;
				$scope.studentsFreeReading=response.data.studentsFreeReading;
				$scope.studentsDigitalResources=response.data.studentsDigitalResources;
				$scope.professionalJournals=response.data.professionalJournals;
				$scope.skillsTrainingRoomArea=response.data.skillsTrainingRoomArea;
				$scope.sharedArea=response.data.sharedArea;
				$scope.skillsTrainingRoomTypes=response.data.skillsTrainingRoomTypes;
				$scope.sharedRoom=response.data.sharedRoom;
				$scope.equipmentCost=response.data.equipmentCost;
				$scope.sharedDeviceValue=response.data.sharedDeviceValue;
				$scope.remark1=response.data.remark.split("#")[0];
				$scope.remark2=response.data.remark.split("#")[1];
				$scope.remark3=response.data.remark.split("#")[2];
				$scope.remark4=response.data.remark.split("#")[3];
				$scope.remark5=response.data.remark.split("#")[4];
				$scope.remark6=response.data.remark.split("#")[5];
				$scope.remark7=response.data.remark.split("#")[6];
				$scope.remark8=response.data.remark.split("#")[7];
				$scope.remark9=response.data.remark.split("#")[8];
				$scope.remark10=response.data.remark.split("#")[9];
				$scope.remark11=response.data.remark.split("#")[10];
				$scope.remark12=response.data.remark.split("#")[11];
				$scope.remark13=response.data.remark.split("#")[12];
				$scope.remark14=response.data.remark.split("#")[13];
				$scope.remark15=response.data.remark.split("#")[14];
				$scope.remark16=response.data.remark.split("#")[15];
			}
		})
	}
	if($getQueryString("isfill")=="1"||$getQueryString("isfill")=="2"){
		$scope.getInfo();
	}
})